home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-12-12 | 8.0 KB | 52 lines | [TEXT/R*ch] |
- /* (C) 1993 Stuart Cheshire <cheshire@cs.stanford.edu>
-
- This sample code can be used to obtain a list of AppleTalk Zones on the
- network. It uses an efficient sorting algorithm to sort a large number
- zone names into alphabetical order in an acceptable length of time.
- I'm making this public because a shocking number of programs, like MacTCP,
- Shiva Net Manager, Spectre Supreme etc. are unable to do this. The Stanford
- network has over 200 zones, and on a Mac SE it takes *over a minute* just
- to open the MacTCP Control Panel!
-
- MAX_ZONES is set to 1000 by default, which should be enough for most networks.
-
- You should create a List Manager list, and then call getzonelist to fill it.
-
- eg.
- static Rect initial_list = { 0,0,0,1 };
- static Point list_cell_size = { 0,0 };
-
- GetDItem(modaldialog, zonelist_item, &di_type, &di_handle, &di_box);
- // Read useritem bounds from DITL
- di_box.right -= 15; // Make room for the vertical scroll bar
- zonelist = LNew(&di_box, &initial_list, list_cell_size, 0, modaldialog,
- TRUE, FALSE, FALSE, TRUE); // Create the list
-
-
- LDoDraw(FALSE, zonelist); // Turn off list drawing
- num_appletalk_zones = getzonelist(zonelist, mydomain.c);
- // Get the list of zones
- pt.h = pt.v = 0;
- LSearch(&myzone.c[1], myzone.c[0], NULL, &pt, zonelist);
- LSetSelect(TRUE, pt, zonelist); // select home zone as default
- LAutoScroll(zonelist); // scroll it into view
- LDoDraw(TRUE, zonelist); // and turn on list drawing again.
-
-
- Tab stops are four spaces
-
- /*****************************************************************************/
-
- #include <AppleTalk.h>
- #include <Packages.h>
-
- #include "StuTypes.h"
- #include "StuAppleTalk.h"
-
- /*****************************************************************************/
-
- #define atpMaxData 578 // size of buffer for zone names
- #define kZIPSocket 6 // the Zone Information Protocol socket
- #define kATPTimeOutVal 3 // re-try ATP SendRequest every 3 seconds
- #define kATPRetryCount 5 // for five times
- #define kGZLCall 0x08000000 // GetZoneL